/**
 * 
 */
package org.reliablesource.prism.gef.editor;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.reliablesource.prism.core.IPrismScreen;
import org.reliablesource.prism.gef.editor.model.ScreenAdapter;


/**
 * @author Jean-Baptiste
 *
 */
public class PrismScreenEditorInput implements IEditorInput, IPersistableElement {

	public static final String MEMENTO_KEY = "ToolExampleID"; //$NON-NLS-1$
	
	final private ScreenAdapter screen;
	
	
	public PrismScreenEditorInput(IPrismScreen obj) {
		this.screen = new ScreenAdapter(obj);
	}
	
	/**
	 * @see org.eclipse.ui.IEditorInput#exists()
	 */
	public boolean exists() {
		return false;
	}

	/**
	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
	 */
	public ImageDescriptor getImageDescriptor() {
		ImageDescriptor result= PlatformUI.getWorkbench().getSharedImages().
					getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
		return result;
	}

	/**
	 * @see org.eclipse.ui.IEditorInput#getName()
	 */
	public String getName() {
		return "";
	}

	/**
	 * @see org.eclipse.ui.IEditorInput#getPersistable()
	 */
	public IPersistableElement getPersistable() {
		return this;
	}

	/**
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
	 */
	public String getToolTipText() {
		return this.getName();
	}

	/**
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
	 */
	public Object getAdapter(Class adapter) {
		return Platform.getAdapterManager().getAdapter(screen.getScreen(), adapter);
	}

	/**
	 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
	 */
	public String getFactoryId() {
		return PrismScreenEditorInputFactory.ID;
	}

	/**
	 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
	 */
	public void saveState(IMemento memento) {
	}
	
    /**
     * 
     */
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        } else {
            return false;
        }
    }

	public ScreenAdapter getInput() {
		return this.screen;
	}
}
